﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;

namespace WindowsFormsApplication1
{
    class XML解析
    {




        private void button1_Click(object sender, EventArgs e)
        {
            System.Text.StringBuilder res = new System.Text.StringBuilder();
            res.Append("<dat>");
            res.Append("<PosDirection>1</PosDirection>");
            res.Append("</dat>");
            XElement root = XElement.Parse(@"" + res.ToString().Trim() + "");
            string DDBH = root.Element("PosDirection").Value;
            //textBox1.Text = DDBH;

           // textBox1.AppendText(ESMes(10, new double[6]));

        }


        private string GetReceiveData(string str)
        {
            XElement root = XElement.Parse(@"" + str.Trim() + "");
            string DDBH = root.Element("PosDirection").Value;
            return DDBH;
        }
        private string ESMes(int m, double[] db)
        {
            System.Text.StringBuilder res = new System.Text.StringBuilder();
            res.Append("<dat>");
            res.Append("<ToPos>" + m.ToString() + "</ToPos>");
            res.Append("<RobotMove>");
            res.Append("<DeltaX>" + db[0].ToString("f2") + "</DeltaX>");
            res.Append("<DeltaY>" + db[1].ToString("f2") + "</DeltaY>");
            res.Append("<DeltaZ>" + db[2].ToString("f2") + "</DeltaZ>");
            res.Append("<DeltaA>" + db[3].ToString("f2") + "</DeltaA>");
            res.Append("<DeltaB>" + db[4].ToString("f2") + "</DeltaB>");
            res.Append("<DeltaC>" + db[5].ToString("f2") + "</DeltaC>");
            res.Append("</RobotMove>");
            res.Append("</dat>");
            return res.ToString().Trim();
        }
    }
}
